package com.ruoyi.lvlian.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.lvlian.domain.ContractBalance;
import com.ruoyi.lvlian.service.IContractBalanceService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 合同额度Controller
 *
 * @author liyuxi
 * @date 2025-06-27
 */
@Api(value = "合同额度", tags = "合同额度Controller")
@RestController
@RequestMapping("/balance")
public class ContractBalanceController extends BaseController {
    @Autowired
    private IContractBalanceService contractBalanceService;

    /**
     * 查询合同额度列表
     */
    @RequiresPermissions("lvlian:balance:list")
    @GetMapping("/list")
    public TableDataInfo list(ContractBalance contractBalance) {
        startPage();
        List<ContractBalance> list = contractBalanceService.selectContractBalanceList(contractBalance);
        return getDataTable(list);
    }


    /**
     * 获取合同额度详细信息
     */
    @RequiresPermissions("lvlian:balance:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(contractBalanceService.selectContractBalanceById(id));
    }


    /**
     * 修改合同额度
     */
//    @RequiresPermissions("lvlian:balance:edit")
    @Log(title = "合同额度", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ContractBalance contractBalance) {
        return toAjax(contractBalanceService.updateContractBalance(contractBalance));
    }

    /**
     * 删除合同额度
     */
//    @RequiresPermissions("lvlian:balance:remove")
    @PostMapping("/remove")
    @Log(title = "合同额度", businessType = BusinessType.DELETE)
    public AjaxResult remove(@RequestBody String[] ids) {
        return toAjax(contractBalanceService.deleteContractBalanceByIds(ids));
    }
}
